
package cn.airnan.dg.controller;

import cn.airnan.dg.service.TopicService;
import cn.airnan.dg.utils.CommonResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 题目相关接口
 */
@RestController
@RequestMapping("/api/topic")
public class TopicController {

    @Resource
    private TopicService service;

    /**
     * 随机获取题目列表
     *
     * @return 题目列表
     */
    @GetMapping("/random")
    public CommonResponse random() {
        try {
            return CommonResponse.success(service.randomTopics(4));
        } catch (Exception e) {
            return CommonResponse.error(e.getMessage());
        }
    }


}
